﻿//==========================================================
// 此代码由TilverNET代码生成工具自动生成，请不要修改
// 代码生成器版本号：1.2
// 作者：landy
// 联系方式：(QQ)86566178
// 创建时间：2014-10-13 11:00:48
//==========================================================

using System;
using System.Text;
using System.Data;
using System.Data.Common;
using System.Collections.Generic;
using System.Linq;
using Tilver.Data;
using Tilver.Data.DataPager;

namespace Weather.DAL.CoWeather
{
	#region EO

	/// <summary>
	///  《dbo.Probe_Aws_Permin(实体类)》
	/// </summary>
	[Serializable]
	public class ProbeAwsPerminEO : IRowMapper<ProbeAwsPerminEO>
	{
		protected long _id;
		protected int _date;
		protected string _time;
		protected string _stationnum;
		protected short? _t;
		protected short? _tmax;
		protected short? _tmin;
		protected short? _fd;
		protected short? _ff;
		protected short? _fdmax;
		protected short? _ffmax;
		protected short? _rain;
		protected short? _p;
		protected short? _rh;
		protected short? _v;


		/// <summary>
		///  《[字段]  [bigint]   自增字段》
		/// </summary>
		public long Id
		{
			get { return _id; }
			set { _id = value;}
		}

		/// <summary>
		///  《[字段]  [int]》
		/// </summary>
		public int Date
		{
			get { return _date; }
			set { _date = value;}
		}

		/// <summary>
		///  《[字段]  [nchar]》
		/// </summary>
		public string Time
		{
			get { return _time; }
			set { _time = value;}
		}

		/// <summary>
		///  《[字段]  [varchar]》
		/// </summary>
		public string Stationnum
		{
			get { return _stationnum; }
			set { _stationnum = value;}
		}

		/// <summary>
		///  《[字段]  [smallint]》
		/// </summary>
		public short? T
		{
			get { return _t; }
			set { _t = value;}
		}

		/// <summary>
		///  《[字段]  [smallint]》
		/// </summary>
		public short? Tmax
		{
			get { return _tmax; }
			set { _tmax = value;}
		}

		/// <summary>
		///  《[字段]  [smallint]》
		/// </summary>
		public short? Tmin
		{
			get { return _tmin; }
			set { _tmin = value;}
		}

		/// <summary>
		///  《[字段]  [smallint]》
		/// </summary>
		public short? Fd
		{
			get { return _fd; }
			set { _fd = value;}
		}

		/// <summary>
		///  《[字段]  [smallint]》
		/// </summary>
		public short? Ff
		{
			get { return _ff; }
			set { _ff = value;}
		}

		/// <summary>
		///  《[字段]  [smallint]》
		/// </summary>
		public short? Fdmax
		{
			get { return _fdmax; }
			set { _fdmax = value;}
		}

		/// <summary>
		///  《[字段]  [smallint]》
		/// </summary>
		public short? Ffmax
		{
			get { return _ffmax; }
			set { _ffmax = value;}
		}

		/// <summary>
		///  《[字段]  [smallint]》
		/// </summary>
		public short? Rain
		{
			get { return _rain; }
			set { _rain = value;}
		}

		/// <summary>
		///  《[字段]  [smallint]》
		/// </summary>
		public short? P
		{
			get { return _p; }
			set { _p = value;}
		}

		/// <summary>
		///  《[字段]  [smallint]》
		/// </summary>
		public short? Rh
		{
			get { return _rh; }
			set { _rh = value;}
		}

		/// <summary>
		///  《[字段]  [smallint]》
		/// </summary>
		public short? V
		{
			get { return _v; }
			set { _v = value;}
		}

		/// <summary>
		/// 默认构造函数
		/// </summary>
		public ProbeAwsPerminEO() 
		{
			Time = string.Empty;
			Stationnum = string.Empty;
		}

		/// <summary>
		/// 自定义构造函数
		/// </summary>
		/// <param name = "id"></param>
		/// <param name = "date"></param>
		/// <param name = "time"></param>
		/// <param name = "stationnum"></param>
		/// <param name = "t"></param>
		/// <param name = "tmax"></param>
		/// <param name = "tmin"></param>
		/// <param name = "fd"></param>
		/// <param name = "ff"></param>
		/// <param name = "fdmax"></param>
		/// <param name = "ffmax"></param>
		/// <param name = "rain"></param>
		/// <param name = "p"></param>
		/// <param name = "rh"></param>
		/// <param name = "v"></param>
		public ProbeAwsPerminEO(long id, int date, string time, string stationnum, short? t, short? tmax, short? tmin, short? fd, short? ff, short? fdmax, short? ffmax, short? rain, short? p, short? rh, short? v) 
		{
			_id = id;
			_date = date;
			_time = time;
			_stationnum = stationnum;
			_t = t;
			_tmax = tmax;
			_tmin = tmin;
			_fd = fd;
			_ff = ff;
			_fdmax = fdmax;
			_ffmax = ffmax;
			_rain = rain;
			_p = p;
			_rh = rh;
			_v = v;
		}


		/// <summary>
		/// 将结果集映射成实体对象
		/// </summary>
		/// <param name = "reader">只进结果集流</param>
		/// <return></return>
		public ProbeAwsPerminEO MapRow(IDataReader reader)
		{
			var ret = new ProbeAwsPerminEO();
			ret.Id = (long)reader["id"];
			ret.Date = (int)reader["date"];
			ret.Time = (string)reader["time"];
			ret.Stationnum = (string)reader["stationnum"];
			ret.T = (reader["t"] is DBNull) ? null : (short?)reader["t"];
			ret.Tmax = (reader["tmax"] is DBNull) ? null : (short?)reader["tmax"];
			ret.Tmin = (reader["tmin"] is DBNull) ? null : (short?)reader["tmin"];
			ret.Fd = (reader["fd"] is DBNull) ? null : (short?)reader["fd"];
			ret.Ff = (reader["ff"] is DBNull) ? null : (short?)reader["ff"];
			ret.Fdmax = (reader["fdmax"] is DBNull) ? null : (short?)reader["fdmax"];
			ret.Ffmax = (reader["ffmax"] is DBNull) ? null : (short?)reader["ffmax"];
			ret.Rain = (reader["rain"] is DBNull) ? null : (short?)reader["rain"];
			ret.P = (reader["p"] is DBNull) ? null : (short?)reader["p"];
			ret.Rh = (reader["rh"] is DBNull) ? null : (short?)reader["rh"];
			ret.V = (reader["v"] is DBNull) ? null : (short?)reader["v"];
			return ret;
		}

		/// <summary>
		/// 将结果集映射成实体对象，返回映射方法
		/// </summary>
		/// <return></return>
		public Func<IDataReader, ProbeAwsPerminEO> GetMapper()
		{
			return MapRow;
		}


	}


	#endregion
	#region MO

	/// <summary>
	///  《dbo.Probe_Aws_Permin(逻辑类)》
	/// </summary>
	public class ProbeAwsPerminMO : DbManagerBase
	{

		#region 构造函数
		/// <summary>
		/// 构造函数
		/// </summary>
		/// <param name = "routeData">路由数据</param>
		public ProbeAwsPerminMO(object routeData = null) : base(routeData) { }

		/// <summary>
		/// 构造函数
		/// </summary>
		/// <param name = "connectionStringName">连接字符串名称</param>
		public ProbeAwsPerminMO(string connectionStringName) : base(connectionStringName) { }

		#endregion

		#region 私有方法
		/// <summary>
		/// 数据库访问操作方法
		/// </summary>
		/// <param name = "sql">SQL语句</param>
		/// <return>返回数据操作对象</return>
		private DbAdoBase AdoBase(string sql)
		{
			return DataBase.CreateDbAdo(sql, CommandType.Text);
		}

		#endregion

		#region Select方法集合

		/// <summary>
		/// 按字段查询
		/// </summary>
		/// <param name = "id"></param>
		/// <param name = "top">获取记录数，当top值小于或等于0时忽略top条件</param>
		/// <param name = "sort">排序表达式，如：field1 ASC,field2 DESC</param>
		/// <param name="tm">事务管理对象</param>
		/// <return></return>
		public List<ProbeAwsPerminEO> SelectById(long id, int top, string sort, TransactionManager tm = null)
		{
			var sql = new StringBuilder();
			var format = new StringBuilder();
			format.Append(@"SELECT {0} [id], [date], [time], [stationnum], [t], [tmax], [tmin], [fd], [ff], [fdmax], [ffmax], [rain], [p], [rh], [v] FROM [dbo].[Probe_Aws_Permin] WHERE [id]=@Id");
			if (!string.IsNullOrEmpty(sort)) format.AppendFormat(" ORDER BY {0} ", sort);
			sql.AppendFormat(format.ToString(), (top > 0) ? string.Format("TOP {0}", top) : string.Empty);
			return AdoBase(sql.ToString())
							.AddInParameter("@Id", id, DbType.Int64, 8)
							.ExecuteList(new ProbeAwsPerminEO().GetMapper(), tm);
		}
		/// <summary>
		/// 按字段查询
		/// </summary>
		/// <param name = "date"></param>
		/// <param name = "top">获取记录数，当top值小于或等于0时忽略top条件</param>
		/// <param name = "sort">排序表达式，如：field1 ASC,field2 DESC</param>
		/// <param name="tm">事务管理对象</param>
		/// <return></return>
		public List<ProbeAwsPerminEO> SelectByDate(int date, int top, string sort, TransactionManager tm = null)
		{
			var sql = new StringBuilder();
			var format = new StringBuilder();
			format.Append(@"SELECT {0} [id], [date], [time], [stationnum], [t], [tmax], [tmin], [fd], [ff], [fdmax], [ffmax], [rain], [p], [rh], [v] FROM [dbo].[Probe_Aws_Permin] WHERE [date]=@Date");
			if (!string.IsNullOrEmpty(sort)) format.AppendFormat(" ORDER BY {0} ", sort);
			sql.AppendFormat(format.ToString(), (top > 0) ? string.Format("TOP {0}", top) : string.Empty);
			return AdoBase(sql.ToString())
							.AddInParameter("@Date", date, DbType.Int32, 4)
							.ExecuteList(new ProbeAwsPerminEO().GetMapper(), tm);
		}
		/// <summary>
		/// 按字段查询
		/// </summary>
		/// <param name = "time"></param>
		/// <param name = "top">获取记录数，当top值小于或等于0时忽略top条件</param>
		/// <param name = "sort">排序表达式，如：field1 ASC,field2 DESC</param>
		/// <param name="tm">事务管理对象</param>
		/// <return></return>
		public List<ProbeAwsPerminEO> SelectByTime(string time, int top, string sort, TransactionManager tm = null)
		{
			var sql = new StringBuilder();
			var format = new StringBuilder();
			format.Append(@"SELECT {0} [id], [date], [time], [stationnum], [t], [tmax], [tmin], [fd], [ff], [fdmax], [ffmax], [rain], [p], [rh], [v] FROM [dbo].[Probe_Aws_Permin] WHERE [time]=@Time");
			if (!string.IsNullOrEmpty(sort)) format.AppendFormat(" ORDER BY {0} ", sort);
			sql.AppendFormat(format.ToString(), (top > 0) ? string.Format("TOP {0}", top) : string.Empty);
			return AdoBase(sql.ToString())
							.AddInParameter("@Time", time, DbType.StringFixedLength, 10)
							.ExecuteList(new ProbeAwsPerminEO().GetMapper(), tm);
		}
		/// <summary>
		/// 按字段查询
		/// </summary>
		/// <param name = "stationnum"></param>
		/// <param name = "top">获取记录数，当top值小于或等于0时忽略top条件</param>
		/// <param name = "sort">排序表达式，如：field1 ASC,field2 DESC</param>
		/// <param name="tm">事务管理对象</param>
		/// <return></return>
		public List<ProbeAwsPerminEO> SelectByStationnum(string stationnum, int top, string sort, TransactionManager tm = null)
		{
			var sql = new StringBuilder();
			var format = new StringBuilder();
			format.Append(@"SELECT {0} [id], [date], [time], [stationnum], [t], [tmax], [tmin], [fd], [ff], [fdmax], [ffmax], [rain], [p], [rh], [v] FROM [dbo].[Probe_Aws_Permin] WHERE [stationnum]=@Stationnum");
			if (!string.IsNullOrEmpty(sort)) format.AppendFormat(" ORDER BY {0} ", sort);
			sql.AppendFormat(format.ToString(), (top > 0) ? string.Format("TOP {0}", top) : string.Empty);
			return AdoBase(sql.ToString())
							.AddInParameter("@Stationnum", stationnum, DbType.AnsiString, 16)
							.ExecuteList(new ProbeAwsPerminEO().GetMapper(), tm);
		}
		/// <summary>
		/// 按字段查询
		/// </summary>
		/// <param name = "t"></param>
		/// <param name = "top">获取记录数，当top值小于或等于0时忽略top条件</param>
		/// <param name = "sort">排序表达式，如：field1 ASC,field2 DESC</param>
		/// <param name="tm">事务管理对象</param>
		/// <return></return>
		public List<ProbeAwsPerminEO> SelectByT(short? t, int top, string sort, TransactionManager tm = null)
		{
			var sql = new StringBuilder();
			var format = new StringBuilder();
			format.Append(@"SELECT {0} [id], [date], [time], [stationnum], [t], [tmax], [tmin], [fd], [ff], [fdmax], [ffmax], [rain], [p], [rh], [v] FROM [dbo].[Probe_Aws_Permin] WHERE [t]=@T");
			if (!string.IsNullOrEmpty(sort)) format.AppendFormat(" ORDER BY {0} ", sort);
			sql.AppendFormat(format.ToString(), (top > 0) ? string.Format("TOP {0}", top) : string.Empty);
			return AdoBase(sql.ToString())
							.AddInParameter("@T", t, DbType.Int16, 2)
							.ExecuteList(new ProbeAwsPerminEO().GetMapper(), tm);
		}
		/// <summary>
		/// 按字段查询
		/// </summary>
		/// <param name = "tmax"></param>
		/// <param name = "top">获取记录数，当top值小于或等于0时忽略top条件</param>
		/// <param name = "sort">排序表达式，如：field1 ASC,field2 DESC</param>
		/// <param name="tm">事务管理对象</param>
		/// <return></return>
		public List<ProbeAwsPerminEO> SelectByTmax(short? tmax, int top, string sort, TransactionManager tm = null)
		{
			var sql = new StringBuilder();
			var format = new StringBuilder();
			format.Append(@"SELECT {0} [id], [date], [time], [stationnum], [t], [tmax], [tmin], [fd], [ff], [fdmax], [ffmax], [rain], [p], [rh], [v] FROM [dbo].[Probe_Aws_Permin] WHERE [tmax]=@Tmax");
			if (!string.IsNullOrEmpty(sort)) format.AppendFormat(" ORDER BY {0} ", sort);
			sql.AppendFormat(format.ToString(), (top > 0) ? string.Format("TOP {0}", top) : string.Empty);
			return AdoBase(sql.ToString())
							.AddInParameter("@Tmax", tmax, DbType.Int16, 2)
							.ExecuteList(new ProbeAwsPerminEO().GetMapper(), tm);
		}
		/// <summary>
		/// 按字段查询
		/// </summary>
		/// <param name = "tmin"></param>
		/// <param name = "top">获取记录数，当top值小于或等于0时忽略top条件</param>
		/// <param name = "sort">排序表达式，如：field1 ASC,field2 DESC</param>
		/// <param name="tm">事务管理对象</param>
		/// <return></return>
		public List<ProbeAwsPerminEO> SelectByTmin(short? tmin, int top, string sort, TransactionManager tm = null)
		{
			var sql = new StringBuilder();
			var format = new StringBuilder();
			format.Append(@"SELECT {0} [id], [date], [time], [stationnum], [t], [tmax], [tmin], [fd], [ff], [fdmax], [ffmax], [rain], [p], [rh], [v] FROM [dbo].[Probe_Aws_Permin] WHERE [tmin]=@Tmin");
			if (!string.IsNullOrEmpty(sort)) format.AppendFormat(" ORDER BY {0} ", sort);
			sql.AppendFormat(format.ToString(), (top > 0) ? string.Format("TOP {0}", top) : string.Empty);
			return AdoBase(sql.ToString())
							.AddInParameter("@Tmin", tmin, DbType.Int16, 2)
							.ExecuteList(new ProbeAwsPerminEO().GetMapper(), tm);
		}
		/// <summary>
		/// 按字段查询
		/// </summary>
		/// <param name = "fd"></param>
		/// <param name = "top">获取记录数，当top值小于或等于0时忽略top条件</param>
		/// <param name = "sort">排序表达式，如：field1 ASC,field2 DESC</param>
		/// <param name="tm">事务管理对象</param>
		/// <return></return>
		public List<ProbeAwsPerminEO> SelectByFd(short? fd, int top, string sort, TransactionManager tm = null)
		{
			var sql = new StringBuilder();
			var format = new StringBuilder();
			format.Append(@"SELECT {0} [id], [date], [time], [stationnum], [t], [tmax], [tmin], [fd], [ff], [fdmax], [ffmax], [rain], [p], [rh], [v] FROM [dbo].[Probe_Aws_Permin] WHERE [fd]=@Fd");
			if (!string.IsNullOrEmpty(sort)) format.AppendFormat(" ORDER BY {0} ", sort);
			sql.AppendFormat(format.ToString(), (top > 0) ? string.Format("TOP {0}", top) : string.Empty);
			return AdoBase(sql.ToString())
							.AddInParameter("@Fd", fd, DbType.Int16, 2)
							.ExecuteList(new ProbeAwsPerminEO().GetMapper(), tm);
		}
		/// <summary>
		/// 按字段查询
		/// </summary>
		/// <param name = "ff"></param>
		/// <param name = "top">获取记录数，当top值小于或等于0时忽略top条件</param>
		/// <param name = "sort">排序表达式，如：field1 ASC,field2 DESC</param>
		/// <param name="tm">事务管理对象</param>
		/// <return></return>
		public List<ProbeAwsPerminEO> SelectByFf(short? ff, int top, string sort, TransactionManager tm = null)
		{
			var sql = new StringBuilder();
			var format = new StringBuilder();
			format.Append(@"SELECT {0} [id], [date], [time], [stationnum], [t], [tmax], [tmin], [fd], [ff], [fdmax], [ffmax], [rain], [p], [rh], [v] FROM [dbo].[Probe_Aws_Permin] WHERE [ff]=@Ff");
			if (!string.IsNullOrEmpty(sort)) format.AppendFormat(" ORDER BY {0} ", sort);
			sql.AppendFormat(format.ToString(), (top > 0) ? string.Format("TOP {0}", top) : string.Empty);
			return AdoBase(sql.ToString())
							.AddInParameter("@Ff", ff, DbType.Int16, 2)
							.ExecuteList(new ProbeAwsPerminEO().GetMapper(), tm);
		}
		/// <summary>
		/// 按字段查询
		/// </summary>
		/// <param name = "fdmax"></param>
		/// <param name = "top">获取记录数，当top值小于或等于0时忽略top条件</param>
		/// <param name = "sort">排序表达式，如：field1 ASC,field2 DESC</param>
		/// <param name="tm">事务管理对象</param>
		/// <return></return>
		public List<ProbeAwsPerminEO> SelectByFdmax(short? fdmax, int top, string sort, TransactionManager tm = null)
		{
			var sql = new StringBuilder();
			var format = new StringBuilder();
			format.Append(@"SELECT {0} [id], [date], [time], [stationnum], [t], [tmax], [tmin], [fd], [ff], [fdmax], [ffmax], [rain], [p], [rh], [v] FROM [dbo].[Probe_Aws_Permin] WHERE [fdmax]=@Fdmax");
			if (!string.IsNullOrEmpty(sort)) format.AppendFormat(" ORDER BY {0} ", sort);
			sql.AppendFormat(format.ToString(), (top > 0) ? string.Format("TOP {0}", top) : string.Empty);
			return AdoBase(sql.ToString())
							.AddInParameter("@Fdmax", fdmax, DbType.Int16, 2)
							.ExecuteList(new ProbeAwsPerminEO().GetMapper(), tm);
		}
		/// <summary>
		/// 按字段查询
		/// </summary>
		/// <param name = "ffmax"></param>
		/// <param name = "top">获取记录数，当top值小于或等于0时忽略top条件</param>
		/// <param name = "sort">排序表达式，如：field1 ASC,field2 DESC</param>
		/// <param name="tm">事务管理对象</param>
		/// <return></return>
		public List<ProbeAwsPerminEO> SelectByFfmax(short? ffmax, int top, string sort, TransactionManager tm = null)
		{
			var sql = new StringBuilder();
			var format = new StringBuilder();
			format.Append(@"SELECT {0} [id], [date], [time], [stationnum], [t], [tmax], [tmin], [fd], [ff], [fdmax], [ffmax], [rain], [p], [rh], [v] FROM [dbo].[Probe_Aws_Permin] WHERE [ffmax]=@Ffmax");
			if (!string.IsNullOrEmpty(sort)) format.AppendFormat(" ORDER BY {0} ", sort);
			sql.AppendFormat(format.ToString(), (top > 0) ? string.Format("TOP {0}", top) : string.Empty);
			return AdoBase(sql.ToString())
							.AddInParameter("@Ffmax", ffmax, DbType.Int16, 2)
							.ExecuteList(new ProbeAwsPerminEO().GetMapper(), tm);
		}
		/// <summary>
		/// 按字段查询
		/// </summary>
		/// <param name = "rain"></param>
		/// <param name = "top">获取记录数，当top值小于或等于0时忽略top条件</param>
		/// <param name = "sort">排序表达式，如：field1 ASC,field2 DESC</param>
		/// <param name="tm">事务管理对象</param>
		/// <return></return>
		public List<ProbeAwsPerminEO> SelectByRain(short? rain, int top, string sort, TransactionManager tm = null)
		{
			var sql = new StringBuilder();
			var format = new StringBuilder();
			format.Append(@"SELECT {0} [id], [date], [time], [stationnum], [t], [tmax], [tmin], [fd], [ff], [fdmax], [ffmax], [rain], [p], [rh], [v] FROM [dbo].[Probe_Aws_Permin] WHERE [rain]=@Rain");
			if (!string.IsNullOrEmpty(sort)) format.AppendFormat(" ORDER BY {0} ", sort);
			sql.AppendFormat(format.ToString(), (top > 0) ? string.Format("TOP {0}", top) : string.Empty);
			return AdoBase(sql.ToString())
							.AddInParameter("@Rain", rain, DbType.Int16, 2)
							.ExecuteList(new ProbeAwsPerminEO().GetMapper(), tm);
		}
		/// <summary>
		/// 按字段查询
		/// </summary>
		/// <param name = "p"></param>
		/// <param name = "top">获取记录数，当top值小于或等于0时忽略top条件</param>
		/// <param name = "sort">排序表达式，如：field1 ASC,field2 DESC</param>
		/// <param name="tm">事务管理对象</param>
		/// <return></return>
		public List<ProbeAwsPerminEO> SelectByP(short? p, int top, string sort, TransactionManager tm = null)
		{
			var sql = new StringBuilder();
			var format = new StringBuilder();
			format.Append(@"SELECT {0} [id], [date], [time], [stationnum], [t], [tmax], [tmin], [fd], [ff], [fdmax], [ffmax], [rain], [p], [rh], [v] FROM [dbo].[Probe_Aws_Permin] WHERE [p]=@P");
			if (!string.IsNullOrEmpty(sort)) format.AppendFormat(" ORDER BY {0} ", sort);
			sql.AppendFormat(format.ToString(), (top > 0) ? string.Format("TOP {0}", top) : string.Empty);
			return AdoBase(sql.ToString())
							.AddInParameter("@P", p, DbType.Int16, 2)
							.ExecuteList(new ProbeAwsPerminEO().GetMapper(), tm);
		}
		/// <summary>
		/// 按字段查询
		/// </summary>
		/// <param name = "rh"></param>
		/// <param name = "top">获取记录数，当top值小于或等于0时忽略top条件</param>
		/// <param name = "sort">排序表达式，如：field1 ASC,field2 DESC</param>
		/// <param name="tm">事务管理对象</param>
		/// <return></return>
		public List<ProbeAwsPerminEO> SelectByRh(short? rh, int top, string sort, TransactionManager tm = null)
		{
			var sql = new StringBuilder();
			var format = new StringBuilder();
			format.Append(@"SELECT {0} [id], [date], [time], [stationnum], [t], [tmax], [tmin], [fd], [ff], [fdmax], [ffmax], [rain], [p], [rh], [v] FROM [dbo].[Probe_Aws_Permin] WHERE [rh]=@Rh");
			if (!string.IsNullOrEmpty(sort)) format.AppendFormat(" ORDER BY {0} ", sort);
			sql.AppendFormat(format.ToString(), (top > 0) ? string.Format("TOP {0}", top) : string.Empty);
			return AdoBase(sql.ToString())
							.AddInParameter("@Rh", rh, DbType.Int16, 2)
							.ExecuteList(new ProbeAwsPerminEO().GetMapper(), tm);
		}
		/// <summary>
		/// 按字段查询
		/// </summary>
		/// <param name = "v"></param>
		/// <param name = "top">获取记录数，当top值小于或等于0时忽略top条件</param>
		/// <param name = "sort">排序表达式，如：field1 ASC,field2 DESC</param>
		/// <param name="tm">事务管理对象</param>
		/// <return></return>
		public List<ProbeAwsPerminEO> SelectByV(short? v, int top, string sort, TransactionManager tm = null)
		{
			var sql = new StringBuilder();
			var format = new StringBuilder();
			format.Append(@"SELECT {0} [id], [date], [time], [stationnum], [t], [tmax], [tmin], [fd], [ff], [fdmax], [ffmax], [rain], [p], [rh], [v] FROM [dbo].[Probe_Aws_Permin] WHERE [v]=@V");
			if (!string.IsNullOrEmpty(sort)) format.AppendFormat(" ORDER BY {0} ", sort);
			sql.AppendFormat(format.ToString(), (top > 0) ? string.Format("TOP {0}", top) : string.Empty);
			return AdoBase(sql.ToString())
							.AddInParameter("@V", v, DbType.Int16, 2)
							.ExecuteList(new ProbeAwsPerminEO().GetMapper(), tm);
		}

		/// <summary>
		/// 按自定义条件查询
		/// </summary>
		/// <param name = "where">自定义条件,where子句</param>
		/// <param name = "top">获取行数</param>
		/// <param name = "sort">排序表达式</param>
		/// <param name = "paras">where子句中定义的参数集合</param>
		/// <param name="tm">事务管理对象</param>
		/// <return></return>
		public List<ProbeAwsPerminEO> Select(string where, int top, string sort, IEnumerable<DbParameter> paras, TransactionManager tm = null)
		{
			var sql = new StringBuilder();
			var format = new StringBuilder();
			format.Append(@"SELECT {0} [id], [date], [time], [stationnum], [t], [tmax], [tmin], [fd], [ff], [fdmax], [ffmax], [rain], [p], [rh], [v] FROM [dbo].[Probe_Aws_Permin] ");
			if (!string.IsNullOrEmpty(where)) format.AppendFormat(" WHERE {0} ", where);
			if (!string.IsNullOrEmpty(sort)) format.AppendFormat(" ORDER BY {0} ", sort);
			sql.AppendFormat(format.ToString(), (top > 0) ? string.Format("TOP {0}", top) : string.Empty);
			return AdoBase(sql.ToString())
							.AddParameters(paras)
							.ExecuteList(new ProbeAwsPerminEO().GetMapper(), tm);
		}

		/// <summary>
		/// 分页查询
		/// </summary>
		/// <param name = "where">条件表达式</param>
		/// <param name = "sort">排序表达式</param>
		/// <param name = "paras">传入参数</param>
		/// <param name = "pageSize">页大小</param>
		/// <param name = "pageIndex">页码</param>
		/// <param name = "recordCount">总记录数，由于计算总记录数影响数据库性能，只有小于或等于0的情况下才返回总记录数</param>
		/// <return>分页数据</return>
		public List<ProbeAwsPerminEO> SelectPager(string where, string sort, IList<DbParameter> paras, long pageSize, long pageIndex, ref long recordCount)
		{
			var sql = new StringBuilder();
			sql.AppendFormat(@"SELECT [id], [date], [time], [stationnum], [t], [tmax], [tmin], [fd], [ff], [fdmax], [ffmax], [rain], [p], [rh], [v] FROM [dbo].[Probe_Aws_Permin]");
			if (!string.IsNullOrEmpty(where)) sql.AppendFormat(" WHERE {0} ", where);
			if (!string.IsNullOrEmpty(sort)) sql.AppendFormat(" ORDER BY {0} ", sort);
			var pager = this.DataBase.CreatePager(sql.ToString(), pageSize);
			pager.AddParameters(paras);
			if (recordCount <= 0)
			{
				recordCount = pager.GetRecordCount();
			}
			return pager.GetPageData(pageIndex).MapToList(new ProbeAwsPerminEO().GetMapper());
		}

		#endregion

		#region Insert方法集合
		/// <summary>
		/// 插入数据，有自增列时，item中自增字段为新增值，否则，返回影响的行数
		/// </summary>
		/// <param name="tm">事务管理对象</param>
		/// <param name = "item">要插入的实体对象</param>
		/// <return></return>
		public int Insert(ProbeAwsPerminEO item, TransactionManager tm = null)
		{
			const string sql = @"INSERT INTO [dbo].[Probe_Aws_Permin] ([date], [time], [stationnum], [t], [tmax], [tmin], [fd], [ff], [fdmax], [ffmax], [rain], [p], [rh], [v]) VALUES (@date, @time, @stationnum, @t, @tmax, @tmin, @fd, @ff, @fdmax, @ffmax, @rain, @p, @rh, @v) ;SELECT SCOPE_IDENTITY();";
			item.Id = long.Parse(AdoBase(sql)
												.AddInParameter("@date", item.Date, DbType.Int32, 4)
												.AddInParameter("@time", item.Time, DbType.StringFixedLength, 10)
												.AddInParameter("@stationnum", item.Stationnum, DbType.AnsiString, 16)
												.AddInParameter("@t", item.T.HasValue ? (object)item.T.Value : DBNull.Value, DbType.Int16, 2)
												.AddInParameter("@tmax", item.Tmax.HasValue ? (object)item.Tmax.Value : DBNull.Value, DbType.Int16, 2)
												.AddInParameter("@tmin", item.Tmin.HasValue ? (object)item.Tmin.Value : DBNull.Value, DbType.Int16, 2)
												.AddInParameter("@fd", item.Fd.HasValue ? (object)item.Fd.Value : DBNull.Value, DbType.Int16, 2)
												.AddInParameter("@ff", item.Ff.HasValue ? (object)item.Ff.Value : DBNull.Value, DbType.Int16, 2)
												.AddInParameter("@fdmax", item.Fdmax.HasValue ? (object)item.Fdmax.Value : DBNull.Value, DbType.Int16, 2)
												.AddInParameter("@ffmax", item.Ffmax.HasValue ? (object)item.Ffmax.Value : DBNull.Value, DbType.Int16, 2)
												.AddInParameter("@rain", item.Rain.HasValue ? (object)item.Rain.Value : DBNull.Value, DbType.Int16, 2)
												.AddInParameter("@p", item.P.HasValue ? (object)item.P.Value : DBNull.Value, DbType.Int16, 2)
												.AddInParameter("@rh", item.Rh.HasValue ? (object)item.Rh.Value : DBNull.Value, DbType.Int16, 2)
												.AddInParameter("@v", item.V.HasValue ? (object)item.V.Value : DBNull.Value, DbType.Int16, 2)
												.ExecuteScalar(tm).ToString());
			return 1;
		}
		#endregion

		#region Update方法集合
		/// <summary>
		/// 按自定义条件更新数据
		/// </summary>
		/// <param name = "set">更新列</param>
		/// <param name = "where">更新条件</param>
		/// <param name = "paras">参数集合</param>
		/// <param name="tm">事务管理对象</param>
		/// <return></return>
		public int Update(string set, string where, IEnumerable<DbParameter> paras, TransactionManager tm = null)
		{
			if (string.IsNullOrEmpty(set)) throw new ArgumentNullException("set");
			var sql = string.Format(@"UPDATE [dbo].[Probe_Aws_Permin] SET {0} {1}", set, (string.IsNullOrEmpty(where) ? string.Empty : " WHERE " + where));
			return AdoBase(sql)
							.AddParameters(paras)
							.ExecuteNonQuery(tm);
		}
		#endregion

		#region Delete方法集合
		/// <summary>
		/// 按字段删除
		/// </summary>
		/// <param name="tm">事务管理对象</param>
		/// <param name = "id"></param>
		public int DeleteById(long id, TransactionManager tm = null)
		{
			const string sql = @"DELETE FROM [dbo].[Probe_Aws_Permin] WHERE [id]=@id";
			return AdoBase(sql)
							.AddInParameter("@id", id, DbType.Int64, 8)
							.ExecuteNonQuery(tm);
		}
		/// <summary>
		/// 按字段删除
		/// </summary>
		/// <param name="tm">事务管理对象</param>
		/// <param name = "date"></param>
		public int DeleteByDate(int date, TransactionManager tm = null)
		{
			const string sql = @"DELETE FROM [dbo].[Probe_Aws_Permin] WHERE [date]=@date";
			return AdoBase(sql)
							.AddInParameter("@date", date, DbType.Int32, 4)
							.ExecuteNonQuery(tm);
		}
		/// <summary>
		/// 按字段删除
		/// </summary>
		/// <param name="tm">事务管理对象</param>
		/// <param name = "time"></param>
		public int DeleteByTime(string time, TransactionManager tm = null)
		{
			const string sql = @"DELETE FROM [dbo].[Probe_Aws_Permin] WHERE [time]=@time";
			return AdoBase(sql)
							.AddInParameter("@time", time, DbType.StringFixedLength, 10)
							.ExecuteNonQuery(tm);
		}
		/// <summary>
		/// 按字段删除
		/// </summary>
		/// <param name="tm">事务管理对象</param>
		/// <param name = "stationnum"></param>
		public int DeleteByStationnum(string stationnum, TransactionManager tm = null)
		{
			const string sql = @"DELETE FROM [dbo].[Probe_Aws_Permin] WHERE [stationnum]=@stationnum";
			return AdoBase(sql)
							.AddInParameter("@stationnum", stationnum, DbType.AnsiString, 16)
							.ExecuteNonQuery(tm);
		}
		/// <summary>
		/// 按字段删除
		/// </summary>
		/// <param name="tm">事务管理对象</param>
		/// <param name = "t"></param>
		public int DeleteByT(short? t, TransactionManager tm = null)
		{
			const string sql = @"DELETE FROM [dbo].[Probe_Aws_Permin] WHERE [t]=@t";
			return AdoBase(sql)
							.AddInParameter("@t", t.HasValue ? (object)t.Value : DBNull.Value, DbType.Int16, 2)
							.ExecuteNonQuery(tm);
		}
		/// <summary>
		/// 按字段删除
		/// </summary>
		/// <param name="tm">事务管理对象</param>
		/// <param name = "tmax"></param>
		public int DeleteByTmax(short? tmax, TransactionManager tm = null)
		{
			const string sql = @"DELETE FROM [dbo].[Probe_Aws_Permin] WHERE [tmax]=@tmax";
			return AdoBase(sql)
							.AddInParameter("@tmax", tmax.HasValue ? (object)tmax.Value : DBNull.Value, DbType.Int16, 2)
							.ExecuteNonQuery(tm);
		}
		/// <summary>
		/// 按字段删除
		/// </summary>
		/// <param name="tm">事务管理对象</param>
		/// <param name = "tmin"></param>
		public int DeleteByTmin(short? tmin, TransactionManager tm = null)
		{
			const string sql = @"DELETE FROM [dbo].[Probe_Aws_Permin] WHERE [tmin]=@tmin";
			return AdoBase(sql)
							.AddInParameter("@tmin", tmin.HasValue ? (object)tmin.Value : DBNull.Value, DbType.Int16, 2)
							.ExecuteNonQuery(tm);
		}
		/// <summary>
		/// 按字段删除
		/// </summary>
		/// <param name="tm">事务管理对象</param>
		/// <param name = "fd"></param>
		public int DeleteByFd(short? fd, TransactionManager tm = null)
		{
			const string sql = @"DELETE FROM [dbo].[Probe_Aws_Permin] WHERE [fd]=@fd";
			return AdoBase(sql)
							.AddInParameter("@fd", fd.HasValue ? (object)fd.Value : DBNull.Value, DbType.Int16, 2)
							.ExecuteNonQuery(tm);
		}
		/// <summary>
		/// 按字段删除
		/// </summary>
		/// <param name="tm">事务管理对象</param>
		/// <param name = "ff"></param>
		public int DeleteByFf(short? ff, TransactionManager tm = null)
		{
			const string sql = @"DELETE FROM [dbo].[Probe_Aws_Permin] WHERE [ff]=@ff";
			return AdoBase(sql)
							.AddInParameter("@ff", ff.HasValue ? (object)ff.Value : DBNull.Value, DbType.Int16, 2)
							.ExecuteNonQuery(tm);
		}
		/// <summary>
		/// 按字段删除
		/// </summary>
		/// <param name="tm">事务管理对象</param>
		/// <param name = "fdmax"></param>
		public int DeleteByFdmax(short? fdmax, TransactionManager tm = null)
		{
			const string sql = @"DELETE FROM [dbo].[Probe_Aws_Permin] WHERE [fdmax]=@fdmax";
			return AdoBase(sql)
							.AddInParameter("@fdmax", fdmax.HasValue ? (object)fdmax.Value : DBNull.Value, DbType.Int16, 2)
							.ExecuteNonQuery(tm);
		}
		/// <summary>
		/// 按字段删除
		/// </summary>
		/// <param name="tm">事务管理对象</param>
		/// <param name = "ffmax"></param>
		public int DeleteByFfmax(short? ffmax, TransactionManager tm = null)
		{
			const string sql = @"DELETE FROM [dbo].[Probe_Aws_Permin] WHERE [ffmax]=@ffmax";
			return AdoBase(sql)
							.AddInParameter("@ffmax", ffmax.HasValue ? (object)ffmax.Value : DBNull.Value, DbType.Int16, 2)
							.ExecuteNonQuery(tm);
		}
		/// <summary>
		/// 按字段删除
		/// </summary>
		/// <param name="tm">事务管理对象</param>
		/// <param name = "rain"></param>
		public int DeleteByRain(short? rain, TransactionManager tm = null)
		{
			const string sql = @"DELETE FROM [dbo].[Probe_Aws_Permin] WHERE [rain]=@rain";
			return AdoBase(sql)
							.AddInParameter("@rain", rain.HasValue ? (object)rain.Value : DBNull.Value, DbType.Int16, 2)
							.ExecuteNonQuery(tm);
		}
		/// <summary>
		/// 按字段删除
		/// </summary>
		/// <param name="tm">事务管理对象</param>
		/// <param name = "p"></param>
		public int DeleteByP(short? p, TransactionManager tm = null)
		{
			const string sql = @"DELETE FROM [dbo].[Probe_Aws_Permin] WHERE [p]=@p";
			return AdoBase(sql)
							.AddInParameter("@p", p.HasValue ? (object)p.Value : DBNull.Value, DbType.Int16, 2)
							.ExecuteNonQuery(tm);
		}
		/// <summary>
		/// 按字段删除
		/// </summary>
		/// <param name="tm">事务管理对象</param>
		/// <param name = "rh"></param>
		public int DeleteByRh(short? rh, TransactionManager tm = null)
		{
			const string sql = @"DELETE FROM [dbo].[Probe_Aws_Permin] WHERE [rh]=@rh";
			return AdoBase(sql)
							.AddInParameter("@rh", rh.HasValue ? (object)rh.Value : DBNull.Value, DbType.Int16, 2)
							.ExecuteNonQuery(tm);
		}
		/// <summary>
		/// 按字段删除
		/// </summary>
		/// <param name="tm">事务管理对象</param>
		/// <param name = "v"></param>
		public int DeleteByV(short? v, TransactionManager tm = null)
		{
			const string sql = @"DELETE FROM [dbo].[Probe_Aws_Permin] WHERE [v]=@v";
			return AdoBase(sql)
							.AddInParameter("@v", v.HasValue ? (object)v.Value : DBNull.Value, DbType.Int16, 2)
							.ExecuteNonQuery(tm);
		}
		/// <summary>
		/// 删除指定条件的记录
		/// </summary>
		/// <param name = "whereClause">自定义删除条件，where子句。如：id=1 and name='aaa'</param>
		/// <param name = "paras">where子句中定义的参数集合</param>
		/// <param name="tm">事务管理对象</param>
		/// <return></return>
		public int Delete(string whereClause, IEnumerable<DbParameter> paras, TransactionManager tm = null)
		{
			var sql = string.Format(@"DELETE FROM [dbo].[Probe_Aws_Permin] {0}", (string.IsNullOrEmpty(whereClause) ? string.Empty : " WHERE " + whereClause));
			return AdoBase(sql)
							.AddParameters(paras)
							.ExecuteNonQuery(tm);
		}
		#endregion

		#region  自定义方法集合
		#endregion

	}


	#endregion
}
